<template>
    <div>
        <el-table
          :data="tableData"
          :header-cell-style="{ 'color': '#FFF','background-color': '#2F4554','text-align': 'center'}"
          :highlight-current-row="true"
          :max-height="1500"
          :size="size"
          v-loading="loading"
          :align="align"
          default-expand-all
          row-key="goodsId"
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
          border
          style="width: 100%">
            <el-table-column prop="goodsId" label="商品ID" sortable  align="center"></el-table-column>
            <el-table-column prop="goodsName" label="商品名称" align="center"></el-table-column>
            <el-table-column prop="merchantName" label="商家名称" align="center"></el-table-column>
            <el-table-column prop="goodsType" label="商品分类" align="center"></el-table-column>
            <el-table-column prop="price" label="价格（元）" align="center"></el-table-column>
            <!-- <el-table-column prop="skillPrice" label="*秒杀价" align="center" v-if="promType == '4'"></el-table-column>
            <el-table-column prop="merchantChannelLimit" label="商家单渠道限购" align="center"></el-table-column>
            <el-table-column prop="storeChannelLimit" label="店铺单渠道限购" align="center"></el-table-column>
            <el-table-column prop="userChannelLimit" label="个人单渠道限购" align="center"></el-table-column> -->
        </el-table>
        <div>
            <el-pagination
            style="float:right;"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageRequest.start"
            :page-sizes="[10, 15, 20]"
            :page-size="pageRequest.limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
export default {
    name:"productTemplate",
    props:{
        promType:{
            type: String,
            default : "4"
        }
    },
    data(){
        return{
            size:"small",
            loading: false,
            align:"center",
            tableData:[],
            total:0,
            pageRequest:{
                start: 1,
                limit: 10
            }
        }
    },
    methods:{
        renderProductTable(res){
            this.loading = false;
            this.tableData = res.rows;
            this.total = res.total;
        },
        init(){
            this.loading = true;
            this.$emit("findProductPage",{"start":this.pageRequest.start,"limit":this.pageRequest.limit});
        },
        handleSizeChange(val){
            this.pageRequest.limit = val;
            this.pageRequest.start = 1;
            this.init();
        },
        handleCurrentChange(val){
            this.pageRequest.start = val;
            this.init();
        }
    },
    mounted(){
        this.init();
    }
}
</script>

<style scoped lang="scss">
  @import '../../../../assets/css/public.scss';
</style>
